package com.mdd.admin.controller;

import com.mdd.admin.service.IMediationRecordService;
import com.mdd.admin.validate.MediationRecordSearchValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.vo.MediationRecordDetailVo;
import com.mdd.admin.vo.MediationRecordListedVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/record")
@Api(tags = "调解记录管理")
public class MediationRecordController {

    @Resource
    IMediationRecordService iMediationRecordService;

    @GetMapping("/list")
    @ApiOperation(value="调解记录列表")
    public AjaxResult<PageResult<MediationRecordListedVo>> list(@Validated PageValidate pageValidate,
                                                     @Validated MediationRecordSearchValidate searchValidate) {
        PageResult<MediationRecordListedVo> list = iMediationRecordService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="调解记录详情")
    public AjaxResult<MediationRecordDetailVo> detail(@Validated @IDMust() @RequestParam("mediationNumber") Integer id) {
        MediationRecordDetailVo detail = iMediationRecordService.detail(id);
        return AjaxResult.success(detail);
    }

}
